package com.lms.logistics_management_system.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lms.logistics_management_system.common.Constants;
import com.lms.logistics_management_system.common.Result;
import com.lms.logistics_management_system.entity.Doctor;
import com.lms.logistics_management_system.entity.Item;
import com.lms.logistics_management_system.entity.Reservation;
import com.lms.logistics_management_system.exception.ServiceException;
import com.lms.logistics_management_system.mapper.DoctorMapper;
import com.lms.logistics_management_system.mapper.ItemMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
public class ItemService extends ServiceImpl<ItemMapper, Item> {

    @Autowired
    private ItemMapper itemMapper;

    public List<Item> getAllItem(){
        return itemMapper.selectList(null);
    }

    private Item getItemInfoByName(String itemName){//通过套餐名查看
        Item one;
        QueryWrapper queryWrapper=new QueryWrapper<Item>();
        queryWrapper.eq("item_name",itemName);
        try {
            if(!StrUtil.isBlank(itemName)) {
                one = getOne(queryWrapper);
            }else{
                throw new ServiceException(Constants.CODE_500,"套餐名不能为空");
            }
        }catch (Exception e){
            e.printStackTrace();
            throw new ServiceException(Constants.CODE_500,"套餐名错误");
        }
        return one;
    }

}
